class Member < ActiveRecord::Base
  belongs_to :accounts
  has_many :guests, :through => :visitors, :dependent => :destroy
  has_many :visitors, :as => :visitorable, :dependent => :destroy
  has_many :friendships, :dependent => :destroy
  has_many :friends ,:through => :friendships, :dependent => :destroy
  has_many :avatars, :as => :avatarable, :dependent => :destroy
  has_many :crews, :dependent => :destroy
  has_many :groups ,:through => :crews, :dependent => :destroy

  SEX = ["男","女"].freeze
  BLOOD = ["A型","B型","O型","AB型","其他"].freeze
  EMOTION = ["单身","恋爱中","已婚"].freeze
  INTENT = ["普通朋友","男女朋友","同性好友","同校邂逅"].freeze
  HEIGHT = ['150cm以下','150-155cm','155-160cm','160-165cm','165-170cm','170-175cm','175-180cm','180-190cm','190-200cm','200cm以上']
  WEIGHT = ['40kg以下','40-45kg','45-50kg','50-55kg','55-60kg','60-65kg','65-70kg','70-80kg','80kg以上']

  validates_presence_of     :nick
  validates_length_of       :nick,    :within => 3..16

  def self.age birth
    ((Date.today - birth.to_date) / 365).floor
  end

end
